<?php 
/* P3(c)

******************************************************************************
                                                                                      
                         __                                                        
                        /__)                                                       
                       /__        P3 - moving Technologie            
                        __)                                                          
                        __)                                                          
                                                                                        
                                                                                        
       Copyright 2009 by p3.co.at                                                                                 
                                                                                        
       visit www.p3.co.at to get more Informations 
       about Teriko - Betriebsdatenerfassung                                                                                 
       - it's not allowed to change this scripts
       - it's not allowed to remove this copyright-tag

       -- you can download the complete license   
          under http://www.teriko.org

 (c) by Patrik Pfaffenbauer and P3 (http://www.p3.co.at)

 | Programname: P3.Teriko
 | Authtor: P3.Verein
 | Coder: Patrik Pfaffenbauer
 | Version: 0.1

 | Change Index
 |_____________________________________________
 |                                             |
 |4.3.2010 Erstellung | Patrik Pfaffenbauer    |
 |_____________________________________________|

******************************************************************************

P3(c) */

class Help extends Base
{
	public function Help()
	{
		$this->title = $GLOBALS['lang']->GetLanguage("Help", "title");
		$this->toolbar = true;
		$this->moduleID = 510;
		$this->permission = GetPermission($this->moduleID);
		
		if(PermissionCount($this->permission) == 0)
		{
			$this->allowed = false;
		}
	}
	
	public function Add()
	{		

	}
	public function Edit()
	{		

	}
	
	public function AnalysPost()
	{
		
	}

	public function PaintFastEdit($id)
	{
		include("./_tables.php");
		$query = $GLOBALS['db']->Query("SELECT * FROM ".$tblhelp." WHERE id=".$id);
		
		if(!($GLOBALS['db']->NumRow($query)))
		{
			$GLOBALS['db']->Query("INSERT INTO ".$tblhelp." (helpID, text) VALUES ('.$id.', 'to edit')");
		}
		
		include("./_tables.php");
		if($this->permission->editPermission)
		{
			echo '
			<table>
				<tr>
					<td>
						<a href="javascript:void(0)" onClick="EditHelpPage(\''.$id.'\');">Bearbeiten</a>
					</td>
				</tr>
			</table>';
		}
		
		$text = $GLOBALS['db']->Fetch($GLOBALS['db']->Query("SELECT * FROM .".$tblhelp." WHERE helpID=".$id))->text;
		
		echo '<div style="display:none;" id="text">
		<textarea id="ckeditor" name="ckeditor">'.$text.'</textarea>
		<input type="button" value="'.$GLOBALS['lang']->GetLanguage("Common", "save").'" name="save" onClick="SaveHelpPage(\''.$id.'\')" />
		</div>';
		echo '<div id="help">'.$text.'</div>';
	}
	public function SaveHelp($id)
	{
		include("./_tables.php");
		
		$query = "UPDATE ".$tblhelp." SET text='".str_replace("%*%", "&",$_POST['text'])."' WHERE helpID=".$id;
		$GLOBALS['db']->Query($query);
		
		echo str_replace("%*%", "&",$_POST['text']);
	}
	public function Toolbar()
	{	
		
	}
	
	public function AddCSS()
	{
			
	}
	public function AddJS()
	{
		
	}
}

?>